$(function(){
    loadUpDownFullloadData();
     //scrollY()
	 document.oncontextmenu = function (event) {
		event.preventDefault();
		var d = {x:event.pageX,y:event.pageY}
        window.parent.postMessage(d,'*');
	 }
});

function scrollY(){
	var ss = 0;
	var dd = setInterval(()=> {
		if(ss == document.getElementById("ulTag").clientHeight){
			clearInterval(dd)
		}
		ss++
		var iwin = $("#sectionTag")
		iwin.scrollTop(ss)
	},30)
}

//查询线路上下行满载率
function loadUpDownFullloadData(){
	var lineId = $("#lineId").val();
	$.ajax({
        type: "post",
        url: "fullload/loadUpDownFullloadData",
        dataType: "json",
        data: {lineId: lineId}, 
        success: function (data) {
        	if(data.length>2){
        		
        		$("#lineName").html(data[0].lineName);
        		$("#lineColorP").css("background",data[0].lineColor)
        		$("#endDate").html(data[0].statisticDate);
        		
        		var domStr = "<div class='road_img'>";
        		for(let i=0;i<data.length;i++){
        			var upImg = "green_up.png";
        			var upSaturationColor = "#00913A";
                	if(data[i].upSaturation>=1){
                		upImg = "yellow_up.png";
                		upSaturationColor = "#F7B52C";
                		
                	}
                	var downImg = "green_down.png";
                	var downSaturationColor = "#00913A";
                	if(data[i].downSaturation>=1){
                		downImg = "yellow_down.png";
                		downSaturationColor = "#F7B52C";
                	}
                    if(i%2==0){
                    	var dom_up = domStr+ "<img src='static/img/line-"+lineId+".png'/>";
                    	dom_up += "<div class='text'>";
                    	dom_up += "<span class='content_one'>"+data[i].sectionName+"</span>";
                    	dom_up += "<div class='flex'>";
                        dom_up += "<p class='content_two'><span style='color:"+upSaturationColor+"'>"+(data[i].upSaturation*100).toFixed(1)+"%</span><img src='static/img/"+upImg+"' /></p>";
                        dom_up += "<p class='content_three'><img src='static/img/"+downImg+"'/><span style='color:"+downSaturationColor+"'>"+(data[i].downSaturation*100).toFixed(1)+"%</span></p>";
                        dom_up += "</div></div></div>";
                        $('.img_for').append(dom_up);
                    }else{
                    	var dom_down = domStr+ "<img src='static/img/line-"+lineId+".png'/>";
                    	dom_down += "<div class='text'>";
                    	dom_down += "<span class='content_one'>"+data[i].sectionName+"</span>";
                    	dom_down += "<div class='flex'>";
                    	dom_down += "<p class='content_twos'"+upSaturationColor+"><span style='color:"+upSaturationColor+"'>"+(data[i].upSaturation*100).toFixed(1)+"%</span><img src='static/img/"+upImg+"'/></p>";
                    	dom_down += "<p class='content_threes'><img src='static/img/"+downImg+"'/><span style='color:"+downSaturationColor+"'>"+(data[i].downSaturation*100).toFixed(1)+"%</span></p>";
                    	dom_down += "</div></div></div>";
	                    $('.img_for').append(dom_down);
	                } 
                }
                let dom_img="<div class='last_con'>";
                dom_img+="<img src='static/img/line-"+lineId+"-end.png'/>";
                dom_img+="<span>"+data[data.length-1].endName+"</span></div>";
        		$('.img_for').append(dom_img);
        	}
    	}
    });
}
